﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;


public class EnumHelper
{

    #region Form表单状态
    /// <summary>
    /// Form表单状态
    /// </summary>
    public enum FormState
    {
        [Description("添加")]add,[Description("修改")]edit
    }
    /// <summary>
    /// Form表单状态字符串
    /// </summary>
    /// <param name="formState_"></param>
    /// <returns></returns>
    public static string FormStateStr(FormState formState_)
    {
        switch (formState_)
        {
            case FormState.add:
                return "添加";
            case FormState.edit:
                return "修改";
            default: return "";
        }
    }
    #endregion

    public enum Plan { [Description("提醒缴纳联盟费")]PAFee = 1,  [Description("提醒打货款")] OrdersMoney, [Description("汇报上月情况")] PreMonth }

    public enum ConfigFile { Game, WinControl, Robot, Basic ,Business,Pay,Refund2Player}
    public enum JsonFile { IPWhite, Debug, Robot, Robot_Coin, Robot_Hour, Robot_Habit_Hour, Robot_Habit_Coin, Robot_Type, Robot_Type_Coin,SMS }
    public enum GameState { Ready, Buy, Deal,  Finish }
    public enum ConData { [Description("内容")]Article=1, [Description("产品")] Product }
    public enum SumType { Int, Double, Money,Coin }
   //
    public enum TableName {
        [Description("用户")] PAUser, 
        [Description("孕婴店")] Store, [Description("供货商")] Supplier,
        [Description("孕婴店管理员")] StoreServer,[Description("供货商管理员")] SupplierServer,
        [Description("财务员")]
        Accountant,
        [Description("采购员")]
        Buyer,
        [Description("收货员")]
        Receiver,
        [Description("配置")] Config,[Description("图片")] Pic,  
        [Description("商品品牌")]Brand, [Description("商品分类")] Category, [Description("商品")] Goods,
        [Description("商品进价历史")] Goods_BuyPrice_Log, [Description("商品售价历史")] Goods_SellPrice_Log, [Description("用户账户金额变动历史")] Account_Change_Log,
        [Description("物流")] Express,[Description("物流详情")] ExpressInfo,
        [Description("订单")] Orders,[Description("订单货品")] Orders_Goods,[Description("订单状态历史")] Orders_State_Log,
        [Description("提款")]Draw,[Description("缴纳联盟费")]PAFee,
        [Description("折扣")]Goods_SaleWay_Discount, [Description("满赠")]Goods_SaleWay_GiftNumber,
         [Description("消息")]Message,
         [Description("团购")]
         GroupBuy,
         [Description("录入员")]
         EntryPerson
    }
    public enum OperateType { [Description("添加")]Add = 1,[Description("编辑")] Update,[Description("删除")] Delete }
    //
    public enum UserState { [Description("正常")]Nomal = 1,[Description("等待审核")] WaitCheck,[Description("锁定")] Lock }
    public enum GoodsState { [Description("正常")]Nomal = 1,[Description("等待审核")] WaitCheck }
    public enum DrawState { [Description("等待处理")]Wait = 1,[Description("同意提款")] Agree,[Description("拒绝提款")] NotAgree }
    //
    public enum Config { Draw,Administrator}
    public enum UserType { 
        [Description("管理员")]Administrator = 1, 
        [Description("孕婴店")] Store,[Description("供货商")] Supplier,
        [Description("财务员")] Accountant, [Description("采购员")] Buyer, [Description("收货员")]Receiver,
        [Description("孕婴店管理员")]
        StoreServer,
        [Description("供货商管理员")]
        SupplierServer,
        [Description("录入员")]
        EntryPerson
        
    }
    /// <summary>
    /// 账户金额变动方式
    /// </summary>
    public enum AccountChangeType { [Description("收入")]Increase = 1,[Description("支出")] Decrease,[Description("冻结")] Freeze,[Description("解冻")] UnFreeze }
    public enum AccountChangeReason { 
        [Description("充值")]Recharge = 1,[Description("赠送")] Gift,[Description("提款")] Draw,
        [Description("提款申请")] ApplyDraw,[Description("拒绝提款申请")] NotAgree_ApplyDraw,[Description("同意提款申请")] _Agree_ApplyDraw,[Description("同意申请提款并提款")] Agree_ApplyDraw,
        //[Description("孕婴店添加商品到订单")] Store_Add_Orders_Goods,[Description("孕婴店从订单删除商品")] Store_Del_Orders_Goods,

         [Description("冻结运费")] ExpectExpressMoney,
        /// <summary>
         /// 此状态不手动调用，由Pay_ExpressMoney自动调用
        /// </summary>
         [Description("成功发货，准备付运费")] _Pay_ExpressMoney,
        /// <summary>
         /// 首先自动解冻冻结的运费，然后支付
        /// </summary>
         [Description("付运费")] Pay_ExpressMoney,

        
        /// <summary>
        /// 收到货款。冻结 目前预计的货款
        /// </summary>
        [Description("收到货款")] GetMoney,
        /// <summary>
        /// 在采购前取消订单。解冻 之前预计的货款
        /// </summary>
        [Description("取消订单")] Cancel_Orders,
        /// <summary>
        /// 准备预支采购款给采购员。解冻 之前预计的货款
        /// </summary>
        //[Description("_准备预支采购款")] _Ready_ExpectPay,
        /// <summary>
        /// 准备预支采购款给采购员。冻结 目前预计的货款
        /// </summary>
        //[Description("预支采购款")] ExpectPay,
        /// <summary>
        /// 取消采购中的订单。解冻 预支货款
        /// </summary>
        //[Description("取消采购订单")] Cancel_BuyOrders,
        /// <summary>
        /// 支付货款前 解冻 预支的货款。此状态不手动调用，由Success_BuyOrders自动调用
        /// </summary>
        [Description("成功采购，准备付款")] _Success_BuyOrders,
        /// <summary>
        /// 支付货款。首先自动解冻预支的货款，然后支付
        /// </summary>
        [Description("成功付款")] Success_BuyOrders,
        [Description("供应商收到货款")] Supplier_GetPay
         }
    /// <summary>
    /// 订单状态
    /// </summary>
    public enum OrdersState {
        /// <summary>
        /// 未选商品
        /// </summary>
        [Description("未选商品")]NoGoods = 0,
        /// <summary>
        /// 孕婴店下单，还未打款
        /// </summary>
        [Description("等待打款")]WaitMoney ,
        /// <summary>
        /// 会计确认收到货款，等待第二天采购员确认准备采购
        /// </summary>
        [Description("已收款")] GetMoney,
        /// <summary>
        /// 会计支出采购款后采购员开始采购
        /// </summary>
        [Description("开始采购")] Buying,
        /// <summary>
        /// 采购员暂停今天的采购，改天再采
        /// </summary>
        [Description("暂停采购")]BuyPause,
        /// <summary>
        /// 采购员采购完毕，补充实际采购数据,等待发货
        /// </summary>
        [Description("采购完毕")] BuyFinish,
        /// <summary>
        /// 采购员填写物流信息后确认发货
        /// </summary>
        [Description("已发货")] HasSend,
        /// <summary>
        /// 用户点击下单(等同于原来等待打款)
        /// </summary>
        [Description("等待打款")]OrderSub,
        /// <summary>
        /// 订单作废
        /// </summary>
        [Description("订单作废")]
        OrderInvalid
        
        
    }


    /// <summary>
    /// 统计表
    /// </summary>
    public enum StatTable { Goods_Stat, Orders_Stat, Store_Stat, Supplier_Stat }
    public enum Goods_Stat_colum
    {
        /// <summary>
        /// 销售数量
        /// </summary>
        [Description("销售数量")]
        Orders_GoodsAmoun,
        /// <summary>
        /// 联盟采购金额
        /// </summary>
        [Description("联盟采购金额")]
        BuyPrice,
        /// <summary>
        /// 孕婴店购买金额
        /// </summary>
        [Description("孕婴店购买金额")]
        SellPrice,
        /// <summary>
        /// 联盟利润金额
        /// </summary>
        [Description("联盟利润金额")]
        Profits
    }
    public enum Orders_Stat
    {
        /// <summary>
        /// 订单数量
        /// </summary>
        [Description("订单数量")]
        Count,
        /// <summary>
        /// 订单联盟采购金额
        /// </summary>
        [Description("订单联盟采购金额")]
        BuyPrice,
        /// <summary>
        /// 订单孕婴店购买金额
        /// </summary>
        [Description("订单孕婴店购买金额")]
        SellPrice,
        /// <summary>
        /// 联盟支付金额
        /// </summary>
        [Description("联盟支付金额")]
        Pay,
        /// <summary>
        /// 联盟利润
        /// </summary>
        [Description("联盟利润")]
        Profits,
        /// <summary>
        /// 订单的货品种类数量
        /// </summary>
        [Description("订单的货品种类数量")]
        Orders_GoodsCount,
        /// <summary>
        /// 订单的货品数量之和
        /// </summary>
        [Description("订单的货品数量之和")]
        Orders_GoodsAmount
    }
    public enum Store_Stat
    {
        /// <summary>
        /// 订单数量
        /// </summary>
        [Description("订单数量")]
        OrdersCount,
        /// <summary>
        /// 购买金额
        /// </summary>
        [Description("购买金额")]
        OrdersSellPrice,
        /// <summary>
        /// 利润贡献
        /// </summary>
        [Description("利润贡献")]
        Profits,
        /// <summary>
        /// 购买的货品种类数量
        /// </summary>
        [Description("购买的货品种类数量")]
        Orders_GoodsCount,
        /// <summary>
        /// 购买的货品数量总和
        /// </summary>
        [Description("购买的货品数量总和")]
        Orders_GoodsAmount
    }
    public enum Supplier_Stat
    {
        /// <summary>
        /// 销售的货品种类数量
        /// </summary>
        [Description("销售的货品种类数量")]
        Orders_GoodsCount,
        /// <summary>
        /// 销售货品数量总和
        /// </summary>
        [Description("销售货品数量总和")]
        Orders_GoodsAmount,
        /// <summary>
        /// 联盟采购总金额
        /// </summary>
        [Description("联盟采购总金额")]
        BuyPrice,
        /// <summary>
        /// 孕婴店购买总金额
        /// </summary>
        [Description("孕婴店购买总金额")]
        SellPrice,
        /// <summary>
        /// 利润贡献
        /// </summary>
        [Description("利润贡献")]
        Profits
    }

    public enum SendSMSstate {
        /// <summary>
        /// 等待发送
        /// </summary>
        [Description("等待发送")]
        Wait=0,
        /// <summary>
        /// 发送中
        /// </summary>
        [Description("发送中")]
        Sending,
        /// <summary>
        /// 发送成功
        /// </summary>
        [Description("发送成功")]
        Success,
        /// <summary>
        /// 发送失败
        /// </summary>
        [Description("发送失败")]
        Fail
    }










    /// <summary>
    /// 获取枚举类子项描述信息
    /// </summary>
    /// <param name="enumSubitem">枚举类子项</param>        
    public static string GetEnumDescription(object enumSubitem)
    {
        enumSubitem = (Enum)enumSubitem;
        string strValue = enumSubitem.ToString();

        FieldInfo fieldinfo = enumSubitem.GetType().GetField(strValue);

        if (fieldinfo != null)
        {

            Object[] objs = fieldinfo.GetCustomAttributes(typeof(DescriptionAttribute), false);

            if (objs == null || objs.Length == 0)
            {
                return strValue;
            }
            else
            {
                DescriptionAttribute da = (DescriptionAttribute)objs[0];
                return da.Description;
            }
        }
        else
        {
            return "";
        }

    }
}
